package com.erp.sys.Util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class WebUtil {

    //  获取request
    public static HttpServletRequest getRequest(){

        HttpServletRequest request =  null;

        // Request上下文
          ServletRequestAttributes  sra =
                  (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();

          request = sra.getRequest();
         return request;

    }

    // 获取Session
    public static  HttpSession getSession(){

        HttpSession session = getRequest().getSession();

        return session;
    }
}
